<template>
	<view style="background: #FFFFFF; margin-top: 22rpx;">
		<view class="content">
			<view class="school" >
				学校名称
			</view>
			<input v-model="form.school_name" placeholder="请输入学校名称" placeholder-style="color: #C2C7CC;"  />
			<view v-if="form.school_name">></view>
			<view v-else  style="color: #C2C7CC;">></view>
		</view>
		<view class="content">
			<view class="school" >
				所学专业
			</view>
			<input v-model="form.major" placeholder="请输入所学专业" placeholder-style="color: #C2C7CC;" />
			<view v-if="form.major">></view>
			<view v-else  style="color: #C2C7CC;">></view>
		</view>
		<view class="content" @click="show=true">
			<view class="school" >
				开始时间
			</view>
			<input disabled='true' v-model="form.start_time" placeholder="请选择开始时间" placeholder-style="color: #C2C7CC;" />
			<view v-if="form.start_time">></view>
			<view v-else  style="color: #C2C7CC;">></view>
		</view>
		<view class="content" @click="showw=true">
			<view class="school" >
				结束时间
			</view>
			<input disabled='true' v-model="form.end_time" placeholder="请选择结束时间" placeholder-style="color: #C2C7CC;" />
			<view v-if="form.end_time">></view>
			<view v-else  style="color: #C2C7CC;">></view>
		</view>
		<view class="content"  @click="sh=true">
			<view class="school" >
				最高学历
			</view>
			<input disabled='true' v-model="edu_type_name" placeholder="请选择最高学历" placeholder-style="color: #C2C7CC;" />
			<view v-if="edu_type_name">></view>
			<view v-else  style="color: #C2C7CC;">></view>
		</view>
		<view class="btn">
			<view class="dl" @click="del" v-if="btn" style="padding: 0 15rpx 30rpx 30rpx;">
				<view class="dlll">
					删除
				</view>
			</view>
			<view class="dl" @click="baocun" v-if="btn==false" style="padding: 30rpx;">
				<view class="dll">
					保存
				</view>
			</view>
			<view class="dl" @click="xgg" v-if="btn" style="padding: 0 30rpx 30rpx 15rpx;">
				<view class="dll">
					修改
				</view>
			</view>
		</view>
		<u-calendar v-model="show" :mode="mode" @change="change"></u-calendar>
		<u-calendar v-model="showw" :mode="mode" @change="changee"></u-calendar>
		<u-select mode="single-column" v-model="sh" :list="listt" @confirm="confirmm"></u-select>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex';
	export default{
		data(){
			return{
				form:{},
				listt: [],
				sh:false,
				btn:false,
				show:false,
				showw:false,
				mode: 'date',
				edu_type_name:'',
			}
		},
		// computed: mapState(['stateData']),
		created() {
			let self=this;
			uni.getStorage({
			    key: 'stateData',
			    success: function (res) {
			        self.stateData=res.data
					console.log(self.stateData,"静态数据")
					self.jt()
			    }
			});
			// this.jt()
		},
		onLoad(e) {
			console.log("E:",e)
			if(e.id){
				this.form.id=e.id;
				this.btn=true;
				this.xg(e)
				console.log("e:",this.xg(e))
			}
		},
		methods:{
			jt(){
				// for(let i in this.stateData.sex_type){
				// 	this.list.push({value:i,label:this.stateData.sex_type[i]})
				// }
				for(let i in this.stateData.edu_type){
					this.listt.push({value:i,label:this.stateData.edu_type[i]})
				}
			},
			async del(){
				const res = await this.post('/Index/User/del_user_resume_edu',{id:this.form.id});
				if(res.code==200){
					uni.showToast({
						title:'删除成功',
						duration:1000,
						icon:'none',
						success() {
							uni.navigateBack({})
						}
					})
				}
			},
			async xg(e) {
				const res = await this.post('/Index/User/get_user_resume_edu',e);
				console.log(res)
				this.form=res.data;
				this.edu_type_name=this.listt[this.form.edu_type].label;
			},
			async xgg() {
				const res = await this.post('/Index/User/edit_user_resume_edu', this.form);
				// console.log(res)
				if(res.code==200){
					uni.showToast({
						title:'修改成功',
						duration:1000,
						icon:'none',
						success() {
							uni.navigateBack({
								
							})
						}
					})
				}
			},
			async baocun() {
				const res = await this.post('/Index/User/add_user_resume_edu', this.form);
				console.log(res)
				if(res.code==200){
					uni.showToast({
						title:'添加成功',
						duration:1000,
						icon:'none',
						success() {
							uni.navigateBack({
								
							})
						}
					})
				}
				console.log(res)
			},
			confirmm(e){
				console.log(e)
				this.form.edu_type=e[0].value;
				this.edu_type_name=e[0].label;
			},
			change(e) {
				console.log(e);
				this.form.start_time = e.result;
			},
			changee(e) {
				console.log(e);
				this.form.end_time = e.result;
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #EDF1F2;
	}
	.btn{
		width: 100%;
		display: flex;
		align-items: center;
		position: fixed;
		bottom: 10rpx;
	}
	.dl {
		width: 100%;
		font-size: 28rpx;
		.dll {
			width: 100%;
			height: 96rpx;
			color: #FFFFFF;
			line-height: 90rpx;
			text-align: center;
			border-radius: 15rpx;
			background-color: #3291F8;
		}
		.dlll{
			width: 100%;
			height: 96rpx;
			color: #FF2525;
			line-height: 90rpx;
			text-align: center;
			border-radius: 15rpx;
			background-color: #FFFFFF;
			border: 1rpx solid #FF2525;
		}
	}
	.content {
		font-size: 28rpx;
		padding: 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 2rpx solid rgba($color: #bbbbbb, $alpha: .5);
		.school{
			width: 250rpx;
			color: #101010;
		}
		input{
			color: #505559;
			font-size: 28rpx;
			text-align: right;
			margin-right: 15rpx;
			width: calc(100% - 250rpx);
		}
	}
</style>
